home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12959 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.9 KB

  1. Path: news.sprintlink.net!datalytics!usenet
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: what is the difference between object orientated programming and lets say C??
  5. Date: Fri, 22 Mar 1996 13:39:20 -0500
  6. Organization: Datalytics, Inc
  7. Message-ID: <3152F3D8.1A67@datalytics.com>
  8. References: <4iqbiq$1hb@atlas.uniserve.com> <3151730F.606B@staff.ichange.com>
  9. NNTP-Posting-Host: 204.62.224.71
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Jesse Liberty wrote:
  16. > Michael Hutchison wrote:
  17. > >...what exactly object orientated programming is.
  18. > Well, this can be a matter of some debate, but I think most of us would agree that OO programming is characterized by:
  19. > 1.  A focus on objects -- programming constructs which include data and methods.  That is, rather than thinking about data
  20. > and what functions can be applied against that data, you think about objects and how they maintain change and report on their
  21. > state.
  22. > 2. Object oriented programming supports encapsulation and polymorphism. Encapsulation is the concept of an object being 
  23. fully
  24. > self-contained. The user of an object should understand what that object can do, but should not care about how that object
  25. > does it.  Polymorphism is the idea that you can ask an object to perform a general action and that action will be
  26. > appropriately carried out based on the specific needs of that specific object. For example, you can ask a window to draw
  27. > itself, and frame windows, dialog windows, text fields, buttons and so forth will each do the right thing based on their 
  28. own
  29. > specific (sub-type based) needs.
  30. > You may want to get a good primer on C++ which introduces each of these concepts and then shows how they are implemented in
  31. > C++.
  32.  
  33. The significant difference, then, is that non-OO languages leave 
  34. to you the encapsulation of data and functions.  That is, you, 
  35. the programmer, are responsible to always keep straight what 
  36. each function does to the data it is given (explicitly through 
  37. parameters and implicity through statics) and how those changes 
  38. affect other functions.  It also helps you control which 
  39. functions may use select data (the access granted to a C++ class 
  40. data member may be public, protected, or private).
  41.  
  42. OO languages correlate data and the functions that operate on 
  43. them.  The correlation--usually by a pair of files--helps track 
  44. and localize changes.  It makes the job of tracking side effects 
  45. easier.
  46.  
  47. The other features, like polymorphism, etc. can be implemented 
  48. (just as the C++ compiler does) through function pointers, etc.  
  49. They may not be trivial, but they don't require the same 
  50. developer diligence.  The compiler can readily enforce the rules 
  51. a class creates about which functions may access which data; 
  52. developers are prone to mistakes in tracking this.
  53.  
  54. -- 
  55. Robert Stewart        | My opinions are usually my own.
  56. Datalytics, Inc.    | stew@datalytics.com
  57.